package com.jsmile.cloud.msgcenter.msg.model;

import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.annotation.TableName;
import com.baomidou.mybatisplus.extension.activerecord.Model;
import com.jsmile.cloud.msgcenter.api.req.ReqNotifyCreate;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author 龚亮
 * @version 1.0
 * @desc 为了薪资破万，还是睡一会儿吧...!
 * @date 2020年06月07日 11:17:04
 */
@ApiModel
@Data
@TableName("t_ms_user_notify")
public class MsUserNotify extends Model<MsUserNotify> {

    private static final long serialVersionUID = 1L;

    @ApiModelProperty(value = "id")
    private Long id;
    @ApiModelProperty(value = "是否阅读 0否 1是")
    private Integer hasRead;
    @ApiModelProperty(value = "接收消息的用户id")
    private Long userId;
    @ApiModelProperty(value = "租户id")
    private Long tenantId;
    @ApiModelProperty(value = "消息id")
    private Long notifyId;
    @ApiModelProperty(value = "remark")
    private String remark;
    @ApiModelProperty(value = "创建时间")
    private java.util.Date createTime;
    @ApiModelProperty(value = "创建者")
    private Long creator;
    @ApiModelProperty(value = "更新时间")
    private java.util.Date updateTime;
    @ApiModelProperty(value = "更新者")
    private Long updater;
    @ApiModelProperty(value = "平台id")
    private Integer platformId;
    @ApiModelProperty(value = "业务id")
    private Integer bizCode;

    public static List<MsUserNotify> create(MsNotify msNotify, ReqNotifyCreate reqNotifyCreate) {
        return reqNotifyCreate.getGetters().stream().map(getter -> {
            MsUserNotify msUserNotify = new MsUserNotify();
            msUserNotify.setCreateTime(new Date());
            msUserNotify.setTenantId(reqNotifyCreate.getCurTenantId());
            msUserNotify.setNotifyId(msNotify.getId());
            msUserNotify.setUserId(getter);
            return msUserNotify;
        }).collect(Collectors.toList());
    }
}
